package club.xyes.zkh.ecommerce.service.impl;

import club.xyes.zkh.ecommerce.common.entity.BaseEntity;
import club.xyes.zkh.ecommerce.dao.BaseMapper;
import club.xyes.zkh.ecommerce.service.BaseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * Create by 郭文梁 2019/4/15 0015 15:18
 * BaseServiceImpl
 * 业务服务组建基类实现
 *
 * @author 郭文梁
 * @data 2019/4/15 0015
 */
public abstract class BaseServiceImpl<T extends BaseEntity> implements BaseService<T> {
    private final BaseMapper<T> mapper;

    BaseServiceImpl(BaseMapper<T> mapper) {
        this.mapper = mapper;
    }

    @Override
    public List<T> all() {
        return mapper.selectAll();
    }

    @Override
    public PageInfo<T> list(int page, int rows) {
        return PageHelper.startPage(page, rows).doSelectPageInfo(mapper::selectAll);
    }
}
